package com.zwj.app.api;

import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

/**
 * kafka消费者
 *
 * @author 张文接
 * @version 1.0
 * @createTime 2024/3/25 21:49
 */
@Component
public class KafkaConsumer {
    /**
     * 监听消费
     * @param record 接收到的具体消息
     */
    @KafkaListener(topics = {"wxy-topic"})//topics 表示需要监听的主题数组
    public void onNormalMessage(ConsumerRecord<String, Object> record) {
        System.out.println("简单消费：" + record.topic() + "-" + record.partition() + "=" + record.value());
    }
}
